package com.study.webSocket;

import org.java_websocket.WebSocket;

import java.net.URI;

/**
 * @author ：ihao ∶）
 * @date ：Created in 2022-05-11 16:03
 */
public class WsClientTest {

    // 根据实际websocket地址更改
    private static String url = "wss://www.dgrlm.com/wss/open/open/socket/news/69795A4D1417AB05E71CE9F7EFB658A6";

    public static void main(String[] args) {
        try {
            WsClient myClient = new WsClient(new URI(url));
            myClient.connect();
            // 判断是否连接成功，未成功后面发送消息时会报错
            while (!myClient.getReadyState().equals(WebSocket.READYSTATE.OPEN)) {
                System.out.println("连接中···请稍后");
                Thread.sleep(1000);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
